import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:yurun_smartmerchants/global.dart';
import 'package:yurun_smartmerchants/page/staff_management.dart';
import 'package:yurun_smartmerchants/routes/routes.dart';
import 'package:oktoast/oktoast.dart';
import 'package:yurun_smartmerchants/utils/app_size.dart';

final GlobalKey<NavigatorState> navigatorKey = new GlobalKey<NavigatorState>();

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // 强制竖屏
  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]);

  Global.init().then((value) => runApp(OKToast(
    child: MyApp(),
    radius: 5,
    dismissOtherOnShow: true,
  )));

}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorKey: navigatorKey,
      initialRoute: welcome_page,
      routes: {
        staff_management_page : (context){
          return StaffManagementPage();
        }
      },
      onGenerateRoute: onGenerateRoute,
      theme: ThemeData(
        primarySwatch: Colors.deepOrange,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      //增加国际化处理
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
       // GlobalEasyRefreshLocalizations.delegate,
      ],
      supportedLocales: [
        const Locale('zh', 'CH'),
        const Locale('en', 'US'),
      ],
      locale: Locale('zh'),
    );
  }
}
